<cfcomponent displayname="Controller" extends="ModelGlue.unity.controller.Controller" output="false">

	<cffunction name="setCFSvnFckFacade" access= "public" returntype="void" output="false">	
		<cfargument name="CFSvnFckFacade" type= "any" required="true">	
		<cfset variables.CFSvnFckFacade = arguments.CFSvnFckFacade/>
	</cffunction>

	<cffunction name="getCFSvnFckFacade" access= "public" returntype="any" output="false">	
		<cfreturn variables.CFSvnFckFacade />
	</cffunction>

	<cffunction name="init" access="public" returntype="any" hint="cfsvn object constructor.">
		<cfargument name="ModelGlue" required="true" type="ModelGlue.ModelGlue" />
		<cfargument name="InstanceName" required="true" type="string" />
		<cfset super.init( arguments.ModelGlue ) />
		<cfreturn this />
	</cffunction>

	<cffunction name="runFckCommand" access="public" returntype="any" hint="runs an fck command.">
	  <cfargument name="event" type="any">
	  <cfset var command = arguments.event.getValue("command","/")>
	  <cfset var currentFolder = arguments.event.getValue("CurrentFolder","/")>
	  <cfset var type = arguments.event.getValue("type")>
	  <cfset var svnFacade = getCFSvnFckFacade()>
	  <cfset var xmlResp = "">
	  <cfswitch expression="#command#">
		  <cfcase value="getFolders">
			  <cfset xmlResp = svnFacade.getFolders(currentFolder)>
			</cfcase>
		  <cfcase value="getFoldersAndFiles">
			  <cfset xmlResp = svnFacade.getFoldersAndFiles(currentFolder)>
			</cfcase>
		  <cfcase value="CreateFolder">
			  <cfset xmlResp = svnFacade.createFolder(currentFolder,arguments.event.getValue("NewFolderName"),arguments.event.getValue("commitMessage"))>
			</cfcase>
		  <cfcase value="CreateFile">
			  <cfset xmlResp = svnFacade.createFile(currentFolder,arguments.event.getValue("NewFileName"),arguments.event.getValue("commitMessage"))>
			</cfcase>
		  <cfcase value="Thumbnail">
			  <cfset xmlResp = svnFacade.thumbnail(currentFolder,arguments.event.getValue("FileName"))>
			</cfcase>
		  <cfcase value="FileUpload">
			  <cfset xmlResp = svnFacade.fileupload(currentFolder,"NewFile",arguments.event.getValue("commitMessage"))>
			</cfcase>
		  <cfcase value="GetUploadProgress">
			  <cfset xmlResp = svnFacade.GetUploadProgress(currentFolder,type)>
			</cfcase>
			
		</cfswitch>
	  <cfset arguments.event.setValue("xmlcontent",xmlResp)>
	</cffunction>


</cfcomponent>